package com.cooper.dao.general;

import java.util.List;

import com.cooper.entity.AdviceSubjectEntity;
import com.cooper.pagination.PageInfo;
import com.cooper.vo.AdviceSearchVo;

import net.paoding.rose.jade.annotation.DAO;
import net.paoding.rose.jade.annotation.Insert;
import net.paoding.rose.jade.annotation.Paged;
import net.paoding.rose.jade.annotation.ReturnGeneratedKeys;
import net.paoding.rose.jade.annotation.SQL;

@DAO
public interface AdviceSubjectDAO {
	
	static final String TABLE_NAME = "d_advice_subject";
	
	@ReturnGeneratedKeys
	@Insert(tableName=TABLE_NAME)
	Long saveEntity(AdviceSubjectEntity entity) throws Exception;

	@SQL("select count(*) from d_advice_subject where deleted='n'"
			+ " #if(null !=:1.userType && '' != :1.userType){ and user_type=:1.userType} "
			+ " #if(null !=:1.subjectType && '' != :1.subjectType){ and subject_type=:1.subjectType } ")
	int querySubjectCount(AdviceSearchVo searchVo) throws Exception;

	@Paged(paramIndex=1)
	@SQL("select * from d_advice_subject t where t.deleted='n'"
			+ " #if(null !=:1.userType && '' != :1.userType){ and user_type=:1.userType} "
			+ " #if(null !=:1.subjectType && '' != :1.subjectType){ and subject_type=:1.subjectType } "
			+ " order by id desc")
	List<AdviceSubjectEntity> querySubjectList(AdviceSearchVo searchVo, PageInfo pageInfo) throws Exception;
	
}
